<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="发布人id" prop="userId">
        <el-input
          v-model="queryParams.userId"
          placeholder="请输入发布人id"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="房源类型_2(1住宅、2别墅、3写字楼 4商铺 5厂房 6仓库 7车位 8土地)" prop="houseCategory">
        <el-input
          v-model="queryParams.houseCategory"
          placeholder="请输入房源类型_2(1住宅、2别墅、3写字楼 4商铺 5厂房 6仓库 7车位 8土地)"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="封面图片url" prop="headerImg">
        <el-input
          v-model="queryParams.headerImg"
          placeholder="请输入封面图片url"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业主姓名;属于核心信息" prop="ownerName">
        <el-input
          v-model="queryParams.ownerName"
          placeholder="请输入业主姓名;属于核心信息"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业主电话;属于核心信息" prop="ownerPhone">
        <el-input
          v-model="queryParams.ownerPhone"
          placeholder="请输入业主电话;属于核心信息"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="额外业主信息json数组;属于核心信息" prop="ownerJson">
        <el-input
          v-model="queryParams.ownerJson"
          placeholder="请输入额外业主信息json数组;属于核心信息"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="小区id;属于核心信息" prop="areaId">
        <el-input
          v-model="queryParams.areaId"
          placeholder="请输入小区id;属于核心信息"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="栋座1栋 、A栋;属于核心信息" prop="buildingBlock">
        <el-input
          v-model="queryParams.buildingBlock"
          placeholder="请输入栋座1栋 、A栋;属于核心信息"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单元 x 单元;属于核心信息" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入单元 x 单元;属于核心信息"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="房号 x 室;属于核心信息" prop="room">
        <el-input
          v-model="queryParams.room"
          placeholder="请输入房号 x 室;属于核心信息"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="盘别" prop="panbie">
        <el-input
          v-model="queryParams.panbie"
          placeholder="请输入盘别"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="价格" prop="price">
        <el-input
          v-model="queryParams.price"
          placeholder="请输入价格"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="底价" prop="lowPrice">
        <el-input
          v-model="queryParams.lowPrice"
          placeholder="请输入底价"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="室" prop="bedroom">
        <el-input
          v-model="queryParams.bedroom"
          placeholder="请输入室"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="厅" prop="livingRoom">
        <el-input
          v-model="queryParams.livingRoom"
          placeholder="请输入厅"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="卫" prop="bathroom">
        <el-input
          v-model="queryParams.bathroom"
          placeholder="请输入卫"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="阳台" prop="balcony">
        <el-input
          v-model="queryParams.balcony"
          placeholder="请输入阳台"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="建筑面积(单位：平方米)" prop="buildingArea">
        <el-input
          v-model="queryParams.buildingArea"
          placeholder="请输入建筑面积(单位：平方米)"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="使用面积(单位：平方米)可用面积" prop="usableArea">
        <el-input
          v-model="queryParams.usableArea"
          placeholder="请输入使用面积(单位：平方米)可用面积"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="第几层" prop="floor">
        <el-input
          v-model="queryParams.floor"
          placeholder="请输入第几层"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="楼栋总共楼层" prop="totalFloor">
        <el-input
          v-model="queryParams.totalFloor"
          placeholder="请输入楼栋总共楼层"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="层高" prop="storeyHeight">
        <el-input
          v-model="queryParams.storeyHeight"
          placeholder="请输入层高"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="朝向(东南西北、东南...)" prop="orientation">
        <el-input
          v-model="queryParams.orientation"
          placeholder="请输入朝向(东南西北、东南...)"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="类型;二手房：普通住宅、复式、公寓、SOHO; 别墅：双拼等" prop="sonCategory">
        <el-input
          v-model="queryParams.sonCategory"
          placeholder="请输入类型;二手房：普通住宅、复式、公寓、SOHO; 别墅：双拼等"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="装修;毛坯、简装、普装、精装、豪装" prop="decoration">
        <el-input
          v-model="queryParams.decoration"
          placeholder="请输入装修;毛坯、简装、普装、精装、豪装"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="卖点" prop="sellingPoint">
        <el-input
          v-model="queryParams.sellingPoint"
          placeholder="请输入卖点"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="厅结构" prop="tingStructure">
        <el-input
          v-model="queryParams.tingStructure"
          placeholder="请输入厅结构"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="占地面积" prop="occupiedArea">
        <el-input
          v-model="queryParams.occupiedArea"
          placeholder="请输入占地面积"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="花园面积" prop="gardenArea">
        <el-input
          v-model="queryParams.gardenArea"
          placeholder="请输入花园面积"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地下室" prop="hasBasement">
        <el-input
          v-model="queryParams.hasBasement"
          placeholder="请输入地下室"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地下室面积" prop="basementArea">
        <el-input
          v-model="queryParams.basementArea"
          placeholder="请输入地下室面积"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车库数量" prop="garageNum">
        <el-input
          v-model="queryParams.garageNum"
          placeholder="请输入车库数量"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车位数量" prop="parkingSpotNum">
        <el-input
          v-model="queryParams.parkingSpotNum"
          placeholder="请输入车位数量"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物业费(元/平方米)" prop="managementFee">
        <el-input
          v-model="queryParams.managementFee"
          placeholder="请输入物业费(元/平方米)"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物业评级(写字楼);甲级、乙级、丙级、其他" prop="propertyEvaluation">
        <el-input
          v-model="queryParams.propertyEvaluation"
          placeholder="请输入物业评级(写字楼);甲级、乙级、丙级、其他"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否可以注册公司" prop="canRegisterCompany">
        <el-input
          v-model="queryParams.canRegisterCompany"
          placeholder="请输入是否可以注册公司"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="来源渠道;上门、电话、洗盘、网络、陌拜、转介绍、老客户" prop="sourceChannel">
        <el-input
          v-model="queryParams.sourceChannel"
          placeholder="请输入来源渠道;上门、电话、洗盘、网络、陌拜、转介绍、老客户"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否有电梯" prop="hasElevator">
        <el-input
          v-model="queryParams.hasElevator"
          placeholder="请输入是否有电梯"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="房屋年龄" prop="buildingAge">
        <el-input
          v-model="queryParams.buildingAge"
          placeholder="请输入房屋年龄"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="房屋年限;满五年、满两年、不满两年" prop="buildingAgeLimit">
        <el-input
          v-model="queryParams.buildingAgeLimit"
          placeholder="请输入房屋年限;满五年、满两年、不满两年"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否是唯一住房" prop="principalResidence">
        <el-input
          v-model="queryParams.principalResidence"
          placeholder="请输入是否是唯一住房"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="建筑结构;钢混、砖混、砖木、钢结构、纯木结构" prop="buildingStructure">
        <el-input
          v-model="queryParams.buildingStructure"
          placeholder="请输入建筑结构;钢混、砖混、砖木、钢结构、纯木结构"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="建筑年代(如1999)" prop="yearBuilt">
        <el-input
          v-model="queryParams.yearBuilt"
          placeholder="请输入建筑年代(如1999)"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产权年限(70年、50年、40年)" prop="ownershipAge">
        <el-input
          v-model="queryParams.ownershipAge"
          placeholder="请输入产权年限(70年、50年、40年)"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="有无抵押(0无 1有)" prop="hasMortgage">
        <el-input
          v-model="queryParams.hasMortgage"
          placeholder="请输入有无抵押(0无 1有)"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建人" prop="createdBy">
        <el-input
          v-model="queryParams.createdBy"
          placeholder="请输入创建人"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="createdTime">
        <el-date-picker clearable
          v-model="queryParams.createdTime"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="更新人" prop="updatedBy">
        <el-input
          v-model="queryParams.updatedBy"
          placeholder="请输入更新人"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="更新时间" prop="updatedTime">
        <el-date-picker clearable
          v-model="queryParams.updatedTime"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择更新时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['house:house:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['house:house:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['house:house:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['house:house:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="houseList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="发布人id" align="center" prop="userId" />
      <el-table-column label="房源类型_1(1二手房、2租房、3新房)" align="center" prop="houseType" />
      <el-table-column label="房源类型_2(1住宅、2别墅、3写字楼 4商铺 5厂房 6仓库 7车位 8土地)" align="center" prop="houseCategory" />
      <el-table-column label="封面图片url" align="center" prop="headerImg" />
      <el-table-column label="室内图片json数组" align="center" prop="innerImgs" />
      <el-table-column label="室外图片json数组" align="center" prop="outerImgs" />
      <el-table-column label="户型图片json数组" align="center" prop="layoutImgs" />
      <el-table-column label="视频地址数组" align="center" prop="videoUrls" />
      <el-table-column label="业主姓名;属于核心信息" align="center" prop="ownerName" />
      <el-table-column label="业主电话;属于核心信息" align="center" prop="ownerPhone" />
      <el-table-column label="额外业主信息json数组;属于核心信息" align="center" prop="ownerJson" />
      <el-table-column label="小区id;属于核心信息" align="center" prop="areaId" />
      <el-table-column label="栋座1栋 、A栋;属于核心信息" align="center" prop="buildingBlock" />
      <el-table-column label="单元 x 单元;属于核心信息" align="center" prop="unit" />
      <el-table-column label="房号 x 室;属于核心信息" align="center" prop="room" />
      <el-table-column label="盘别" align="center" prop="panbie" />
      <el-table-column label="价格" align="center" prop="price" />
      <el-table-column label="底价" align="center" prop="lowPrice" />
      <el-table-column label="室" align="center" prop="bedroom" />
      <el-table-column label="厅" align="center" prop="livingRoom" />
      <el-table-column label="卫" align="center" prop="bathroom" />
      <el-table-column label="阳台" align="center" prop="balcony" />
      <el-table-column label="建筑面积(单位：平方米)" align="center" prop="buildingArea" />
      <el-table-column label="使用面积(单位：平方米)可用面积" align="center" prop="usableArea" />
      <el-table-column label="第几层" align="center" prop="floor" />
      <el-table-column label="楼栋总共楼层" align="center" prop="totalFloor" />
      <el-table-column label="层高" align="center" prop="storeyHeight" />
      <el-table-column label="朝向(东南西北、东南...)" align="center" prop="orientation" />
      <el-table-column label="类型;二手房：普通住宅、复式、公寓、SOHO; 别墅：双拼等" align="center" prop="sonCategory" />
      <el-table-column label="装修;毛坯、简装、普装、精装、豪装" align="center" prop="decoration" />
      <el-table-column label="卖点" align="center" prop="sellingPoint" />
      <el-table-column label="厅结构" align="center" prop="tingStructure" />
      <el-table-column label="占地面积" align="center" prop="occupiedArea" />
      <el-table-column label="花园面积" align="center" prop="gardenArea" />
      <el-table-column label="地下室" align="center" prop="hasBasement" />
      <el-table-column label="地下室面积" align="center" prop="basementArea" />
      <el-table-column label="车库数量" align="center" prop="garageNum" />
      <el-table-column label="车位数量" align="center" prop="parkingSpotNum" />
      <el-table-column label="物业费(元/平方米)" align="center" prop="managementFee" />
      <el-table-column label="物业评级(写字楼);甲级、乙级、丙级、其他" align="center" prop="propertyEvaluation" />
      <el-table-column label="是否可以注册公司" align="center" prop="canRegisterCompany" />
      <el-table-column label="来源渠道;上门、电话、洗盘、网络、陌拜、转介绍、老客户" align="center" prop="sourceChannel" />
      <el-table-column label="是否有电梯" align="center" prop="hasElevator" />
      <el-table-column label="房屋年龄" align="center" prop="buildingAge" />
      <el-table-column label="房屋年限;满五年、满两年、不满两年" align="center" prop="buildingAgeLimit" />
      <el-table-column label="是否是唯一住房" align="center" prop="principalResidence" />
      <el-table-column label="建筑结构;钢混、砖混、砖木、钢结构、纯木结构" align="center" prop="buildingStructure" />
      <el-table-column label="建筑年代(如1999)" align="center" prop="yearBuilt" />
      <el-table-column label="产权性质;商品房、商住两用、经济适用房、安置房、公房、小产权、其他" align="center" prop="ownershipType" />
      <el-table-column label="产权年限(70年、50年、40年)" align="center" prop="ownershipAge" />
      <el-table-column label="有无抵押(0无 1有)" align="center" prop="hasMortgage" />
      <el-table-column label="备注" align="center" prop="memo" />
      <el-table-column label="创建人" align="center" prop="createdBy" />
      <el-table-column label="创建时间" align="center" prop="createdTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.createdTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新人" align="center" prop="updatedBy" />
      <el-table-column label="更新时间" align="center" prop="updatedTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.updatedTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['house:house:edit']">修改</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['house:house:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改企业房源对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form ref="houseRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="发布人id" prop="userId">
          <el-input v-model="form.userId" placeholder="请输入发布人id" />
        </el-form-item>
        <el-form-item label="房源类型_2(1住宅、2别墅、3写字楼 4商铺 5厂房 6仓库 7车位 8土地)" prop="houseCategory">
          <el-input v-model="form.houseCategory" placeholder="请输入房源类型_2(1住宅、2别墅、3写字楼 4商铺 5厂房 6仓库 7车位 8土地)" />
        </el-form-item>
        <el-form-item label="封面图片url" prop="headerImg">
          <el-input v-model="form.headerImg" placeholder="请输入封面图片url" />
        </el-form-item>
        <el-form-item label="室内图片json数组" prop="innerImgs">
          <el-input v-model="form.innerImgs" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="室外图片json数组" prop="outerImgs">
          <el-input v-model="form.outerImgs" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="户型图片json数组" prop="layoutImgs">
          <el-input v-model="form.layoutImgs" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="视频地址数组" prop="videoUrls">
          <el-input v-model="form.videoUrls" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="业主姓名;属于核心信息" prop="ownerName">
          <el-input v-model="form.ownerName" placeholder="请输入业主姓名;属于核心信息" />
        </el-form-item>
        <el-form-item label="业主电话;属于核心信息" prop="ownerPhone">
          <el-input v-model="form.ownerPhone" placeholder="请输入业主电话;属于核心信息" />
        </el-form-item>
        <el-form-item label="额外业主信息json数组;属于核心信息" prop="ownerJson">
          <el-input v-model="form.ownerJson" placeholder="请输入额外业主信息json数组;属于核心信息" />
        </el-form-item>
        <el-form-item label="小区id;属于核心信息" prop="areaId">
          <el-input v-model="form.areaId" placeholder="请输入小区id;属于核心信息" />
        </el-form-item>
        <el-form-item label="栋座1栋 、A栋;属于核心信息" prop="buildingBlock">
          <el-input v-model="form.buildingBlock" placeholder="请输入栋座1栋 、A栋;属于核心信息" />
        </el-form-item>
        <el-form-item label="单元 x 单元;属于核心信息" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单元 x 单元;属于核心信息" />
        </el-form-item>
        <el-form-item label="房号 x 室;属于核心信息" prop="room">
          <el-input v-model="form.room" placeholder="请输入房号 x 室;属于核心信息" />
        </el-form-item>
        <el-form-item label="盘别" prop="panbie">
          <el-input v-model="form.panbie" placeholder="请输入盘别" />
        </el-form-item>
        <el-form-item label="价格" prop="price">
          <el-input v-model="form.price" placeholder="请输入价格" />
        </el-form-item>
        <el-form-item label="底价" prop="lowPrice">
          <el-input v-model="form.lowPrice" placeholder="请输入底价" />
        </el-form-item>
        <el-form-item label="室" prop="bedroom">
          <el-input v-model="form.bedroom" placeholder="请输入室" />
        </el-form-item>
        <el-form-item label="厅" prop="livingRoom">
          <el-input v-model="form.livingRoom" placeholder="请输入厅" />
        </el-form-item>
        <el-form-item label="卫" prop="bathroom">
          <el-input v-model="form.bathroom" placeholder="请输入卫" />
        </el-form-item>
        <el-form-item label="阳台" prop="balcony">
          <el-input v-model="form.balcony" placeholder="请输入阳台" />
        </el-form-item>
        <el-form-item label="建筑面积(单位：平方米)" prop="buildingArea">
          <el-input v-model="form.buildingArea" placeholder="请输入建筑面积(单位：平方米)" />
        </el-form-item>
        <el-form-item label="使用面积(单位：平方米)可用面积" prop="usableArea">
          <el-input v-model="form.usableArea" placeholder="请输入使用面积(单位：平方米)可用面积" />
        </el-form-item>
        <el-form-item label="第几层" prop="floor">
          <el-input v-model="form.floor" placeholder="请输入第几层" />
        </el-form-item>
        <el-form-item label="楼栋总共楼层" prop="totalFloor">
          <el-input v-model="form.totalFloor" placeholder="请输入楼栋总共楼层" />
        </el-form-item>
        <el-form-item label="层高" prop="storeyHeight">
          <el-input v-model="form.storeyHeight" placeholder="请输入层高" />
        </el-form-item>
        <el-form-item label="朝向(东南西北、东南...)" prop="orientation">
          <el-input v-model="form.orientation" placeholder="请输入朝向(东南西北、东南...)" />
        </el-form-item>
        <el-form-item label="类型;二手房：普通住宅、复式、公寓、SOHO; 别墅：双拼等" prop="sonCategory">
          <el-input v-model="form.sonCategory" placeholder="请输入类型;二手房：普通住宅、复式、公寓、SOHO; 别墅：双拼等" />
        </el-form-item>
        <el-form-item label="装修;毛坯、简装、普装、精装、豪装" prop="decoration">
          <el-input v-model="form.decoration" placeholder="请输入装修;毛坯、简装、普装、精装、豪装" />
        </el-form-item>
        <el-form-item label="卖点" prop="sellingPoint">
          <el-input v-model="form.sellingPoint" placeholder="请输入卖点" />
        </el-form-item>
        <el-form-item label="厅结构" prop="tingStructure">
          <el-input v-model="form.tingStructure" placeholder="请输入厅结构" />
        </el-form-item>
        <el-form-item label="占地面积" prop="occupiedArea">
          <el-input v-model="form.occupiedArea" placeholder="请输入占地面积" />
        </el-form-item>
        <el-form-item label="花园面积" prop="gardenArea">
          <el-input v-model="form.gardenArea" placeholder="请输入花园面积" />
        </el-form-item>
        <el-form-item label="地下室" prop="hasBasement">
          <el-input v-model="form.hasBasement" placeholder="请输入地下室" />
        </el-form-item>
        <el-form-item label="地下室面积" prop="basementArea">
          <el-input v-model="form.basementArea" placeholder="请输入地下室面积" />
        </el-form-item>
        <el-form-item label="车库数量" prop="garageNum">
          <el-input v-model="form.garageNum" placeholder="请输入车库数量" />
        </el-form-item>
        <el-form-item label="车位数量" prop="parkingSpotNum">
          <el-input v-model="form.parkingSpotNum" placeholder="请输入车位数量" />
        </el-form-item>
        <el-form-item label="物业费(元/平方米)" prop="managementFee">
          <el-input v-model="form.managementFee" placeholder="请输入物业费(元/平方米)" />
        </el-form-item>
        <el-form-item label="物业评级(写字楼);甲级、乙级、丙级、其他" prop="propertyEvaluation">
          <el-input v-model="form.propertyEvaluation" placeholder="请输入物业评级(写字楼);甲级、乙级、丙级、其他" />
        </el-form-item>
        <el-form-item label="是否可以注册公司" prop="canRegisterCompany">
          <el-input v-model="form.canRegisterCompany" placeholder="请输入是否可以注册公司" />
        </el-form-item>
        <el-form-item label="来源渠道;上门、电话、洗盘、网络、陌拜、转介绍、老客户" prop="sourceChannel">
          <el-input v-model="form.sourceChannel" placeholder="请输入来源渠道;上门、电话、洗盘、网络、陌拜、转介绍、老客户" />
        </el-form-item>
        <el-form-item label="是否有电梯" prop="hasElevator">
          <el-input v-model="form.hasElevator" placeholder="请输入是否有电梯" />
        </el-form-item>
        <el-form-item label="房屋年龄" prop="buildingAge">
          <el-input v-model="form.buildingAge" placeholder="请输入房屋年龄" />
        </el-form-item>
        <el-form-item label="房屋年限;满五年、满两年、不满两年" prop="buildingAgeLimit">
          <el-input v-model="form.buildingAgeLimit" placeholder="请输入房屋年限;满五年、满两年、不满两年" />
        </el-form-item>
        <el-form-item label="是否是唯一住房" prop="principalResidence">
          <el-input v-model="form.principalResidence" placeholder="请输入是否是唯一住房" />
        </el-form-item>
        <el-form-item label="建筑结构;钢混、砖混、砖木、钢结构、纯木结构" prop="buildingStructure">
          <el-input v-model="form.buildingStructure" placeholder="请输入建筑结构;钢混、砖混、砖木、钢结构、纯木结构" />
        </el-form-item>
        <el-form-item label="建筑年代(如1999)" prop="yearBuilt">
          <el-input v-model="form.yearBuilt" placeholder="请输入建筑年代(如1999)" />
        </el-form-item>
        <el-form-item label="产权年限(70年、50年、40年)" prop="ownershipAge">
          <el-input v-model="form.ownershipAge" placeholder="请输入产权年限(70年、50年、40年)" />
        </el-form-item>
        <el-form-item label="有无抵押(0无 1有)" prop="hasMortgage">
          <el-input v-model="form.hasMortgage" placeholder="请输入有无抵押(0无 1有)" />
        </el-form-item>
        <el-form-item label="备注" prop="memo">
          <el-input v-model="form.memo" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="创建人" prop="createdBy">
          <el-input v-model="form.createdBy" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="创建时间" prop="createdTime">
          <el-date-picker clearable
            v-model="form.createdTime"
            type="date"
            value-format="YYYY-MM-DD"
            placeholder="请选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="更新人" prop="updatedBy">
          <el-input v-model="form.updatedBy" placeholder="请输入更新人" />
        </el-form-item>
        <el-form-item label="更新时间" prop="updatedTime">
          <el-date-picker clearable
            v-model="form.updatedTime"
            type="date"
            value-format="YYYY-MM-DD"
            placeholder="请选择更新时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="0 表示未删除，1 表示已逻辑删除" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入0 表示未删除，1 表示已逻辑删除" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="House">
import { listHouse, getHouse, delHouse, addHouse, updateHouse } from "@/api/house/house"

const { proxy } = getCurrentInstance()

const houseList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    userId: null,
    houseType: null,
    houseCategory: null,
    headerImg: null,
    innerImgs: null,
    outerImgs: null,
    layoutImgs: null,
    videoUrls: null,
    ownerName: null,
    ownerPhone: null,
    ownerJson: null,
    areaId: null,
    buildingBlock: null,
    unit: null,
    room: null,
    panbie: null,
    price: null,
    lowPrice: null,
    bedroom: null,
    livingRoom: null,
    bathroom: null,
    balcony: null,
    buildingArea: null,
    usableArea: null,
    floor: null,
    totalFloor: null,
    storeyHeight: null,
    orientation: null,
    sonCategory: null,
    decoration: null,
    sellingPoint: null,
    tingStructure: null,
    occupiedArea: null,
    gardenArea: null,
    hasBasement: null,
    basementArea: null,
    garageNum: null,
    parkingSpotNum: null,
    managementFee: null,
    propertyEvaluation: null,
    canRegisterCompany: null,
    sourceChannel: null,
    hasElevator: null,
    buildingAge: null,
    buildingAgeLimit: null,
    principalResidence: null,
    buildingStructure: null,
    yearBuilt: null,
    ownershipType: null,
    ownershipAge: null,
    hasMortgage: null,
    memo: null,
    createdBy: null,
    createdTime: null,
    updatedBy: null,
    updatedTime: null,
  },
  rules: {
  }
})

const { queryParams, form, rules } = toRefs(data)

/** 查询企业房源列表 */
function getList() {
  loading.value = true
  listHouse(queryParams.value).then(response => {
    houseList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel() {
  open.value = false
  reset()
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    userId: null,
    houseType: null,
    houseCategory: null,
    headerImg: null,
    innerImgs: null,
    outerImgs: null,
    layoutImgs: null,
    videoUrls: null,
    ownerName: null,
    ownerPhone: null,
    ownerJson: null,
    areaId: null,
    buildingBlock: null,
    unit: null,
    room: null,
    panbie: null,
    price: null,
    lowPrice: null,
    bedroom: null,
    livingRoom: null,
    bathroom: null,
    balcony: null,
    buildingArea: null,
    usableArea: null,
    floor: null,
    totalFloor: null,
    storeyHeight: null,
    orientation: null,
    sonCategory: null,
    decoration: null,
    sellingPoint: null,
    tingStructure: null,
    occupiedArea: null,
    gardenArea: null,
    hasBasement: null,
    basementArea: null,
    garageNum: null,
    parkingSpotNum: null,
    managementFee: null,
    propertyEvaluation: null,
    canRegisterCompany: null,
    sourceChannel: null,
    hasElevator: null,
    buildingAge: null,
    buildingAgeLimit: null,
    principalResidence: null,
    buildingStructure: null,
    yearBuilt: null,
    ownershipType: null,
    ownershipAge: null,
    hasMortgage: null,
    memo: null,
    createdBy: null,
    createdTime: null,
    updatedBy: null,
    updatedTime: null,
    delFlag: null
  }
  proxy.resetForm("houseRef")
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef")
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id)
  single.value = selection.length != 1
  multiple.value = !selection.length
}

/** 新增按钮操作 */
function handleAdd() {
  reset()
  open.value = true
  title.value = "添加企业房源"
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset()
  const _id = row.id || ids.value
  getHouse(_id).then(response => {
    form.value = response.data
    open.value = true
    title.value = "修改企业房源"
  })
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["houseRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updateHouse(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addHouse(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value
  proxy.$modal.confirm('是否确认删除企业房源编号为"' + _ids + '"的数据项？').then(function() {
    return delHouse(_ids)
  }).then(() => {
    getList()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => {})
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('house/house/export', {
    ...queryParams.value
  }, `house_${new Date().getTime()}.xlsx`)
}

getList()
</script>
